import { ref } from "vue";
import { defineStore } from "pinia";
import { getCategoryAPI } from '@/api/layout';

export const useCategoryStore = defineStore('category', () => {
    let category = ref([])

    const getCategory = async () => {
        const { data: res } = await getCategoryAPI();
        if (res.code !== '1') return ElMessage.error(res.msg)
        category.value = res.result
    }

    return {
        category,
        getCategory
    }
})